package com.ice.body.business.controller;
import com.ice.body.business.model.VideoMonitorModel;
import com.ice.body.business.service.VideoMonitorService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import com.ice.base.controller.BaseController;
import com.github.pagehelper.PageHelper;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.Instant;

import com.ice.base.result.ResponseResult;
import com.ice.base.result.AjaxResult;
import springfox.documentation.annotations.ApiIgnore;

import java.util.ArrayList;
/**
 * Created with GuoYanBin.
 * Description:
 * Date: 2021-06-18
 * Time: 02:58
 */
@RestController
@ApiIgnore(value = "业务接口-监控录像")
public class VideoMonitorController extends BaseController{
    //---------------------------业务接口-监控录像-----------------------start
    @Resource
    private VideoMonitorService videoMonitorService;


    
    @ApiOperation(value = "业务接口-监控录像-新增")
    @PostMapping("/api/VideoMonitor/insert")
    public AjaxResult<VideoMonitorModel> insert_VideoMonitor(VideoMonitorModel model) {
        AjaxResult r = ResponseResult.success();
        try{
            model.initBase(model);
            videoMonitorService.insert(model);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }

    @ApiOperation(value = "业务接口-监控录像-删除")
    @PostMapping("/api/VideoMonitor/deleteById")
    public AjaxResult<VideoMonitorModel> deleteById_VideoMonitor(@RequestParam("id") String id) {
        AjaxResult r = ResponseResult.success();
        try{
            videoMonitorService.delete(id);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }

    @ApiOperation(value = "业务接口-监控录像-更新")
    @PostMapping("/api/VideoMonitor/updateById")
    public AjaxResult<VideoMonitorModel> update_VideoMonitor(VideoMonitorModel model) {
        AjaxResult r = ResponseResult.success();
        try{
            videoMonitorService.update(model);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }

    @ApiOperation(value = "业务接口-监控录像-查询一个")
    @PostMapping("/api/VideoMonitor/selectById")
    public AjaxResult<VideoMonitorModel> selectById_VideoMonitor(@RequestParam("id") String id) {
        AjaxResult r = ResponseResult.success();
        try{
           VideoMonitorModel model = videoMonitorService.selectById(id);
           r.setData(model);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }

/*    @ApiOperation(value = "业务接口-监控录像-查询多个")
    @PostMapping("/api/VideoMonitor/selectAll")
    public Result<VideoMonitorModel> selectList_VideoMonitor(VideoMonitorModel model) {
        Result r = ResponseResult.success();
        try{
           List<VideoMonitorModel> list = videoMonitorService.selectListByModel(model);
           r.setData(list);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }*/

    @ApiOperation(value = "业务接口-监控录像-查询分页")
    @PostMapping("/api/VideoMonitor/selectListByPageHelper")
    public AjaxResult<VideoMonitorModel> selectListByPageHelper_VideoMonitor
                                (@RequestParam(name = "pageSize") Integer pageSize,
                                 @RequestParam(name = "pageNum") Integer pageNum,
                                 VideoMonitorModel model){
        AjaxResult r = ResponseResult.success();
        ArrayList list;
      /*  SysLoginModel currLoginModel = BaseUtil.getCurrLoginModel();
        model.setUserId(currLoginModel.getId());*/
        try{
           PageHelper.startPage(pageNum, pageSize);
           list = videoMonitorService.selectListByModel(model);
           getReturnResultByPage(r,list);
        }catch (Exception e){
            e.printStackTrace();
            r = ResponseResult.error();   
        }
        return r;
    }
    //---------------------------业务接口-监控录像-----------------------end
}
